const cloud = require('wx-server-sdk');
cloud.init({
  env:"xiaotiao-6gcr9hxy3d8aa90f"
});
const db = cloud.database();
exports.main = async (event, context) => {
  var openid = event.openid;
  var records = [];
  console.log("我服了")
  try{
    console.log("我他妈真的是要烦死了")
    await db.collection('ClockInRecords').where({
      _openid: openid
    }).get().then(res=>{
      console.log(res)
      records = res.data[0]._records
      console.log(records)
    }).catch(res=>{
      console.log("我靠")
      console.log(res)
      records = null
    })
    console.log(records)
    return{
      event:event,
      success:true,
      records:records
    };
  }catch(e){
    console.log("???????")
    return{
      event:event,
      success:false,
      records:records
    }
  }
}